<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单事件类型</title>
</head>
<body>
    <form action="#" id="form">
        <input type="text" id="username">
        <input type="submit" value="提交">
        <input type="reset" value="重置">
    </form>
    
    <script>
        username.onfocus = function(){
            console.log('获取焦点')
        }
        username.onblur = function(){
            console.log('失去焦点')
        }
        //获取焦点和失去焦点的时候内容不一样出发
        username.onchange = function(){
            console.log('change焦点')
        }
        username.oninput = function(){
            console.log('输入事件')
        }
        form.onsubmit = function(){
            console.log('表单提交')
            return false
        }
        form.onreset = function(){
            console.log('表单重置')
        }
    </script>
</body>
</html>